<?php
include_once("../includes/global.php");
$script_tmp = explode('/', $_SERVER['SCRIPT_NAME']);
$sctiptName = array_pop($script_tmp);
@include_once("auth.php");
//=========================================
if(empty($_GET['ctype']))
	$_GET['ctype']=0;
$type='user_right'.$_GET['ctype'];
if(!empty($_POST['submit']))
{
	/****更新缓存文件*********/
	$write_config_con_array=$_POST['index'];//从库里取出数据生成数组
	$write_config_con_str=serialize($write_config_con_array);//将数组序列化后生成字符串
	$write_config_con_str=str_replace("'","\'",$write_config_con_str);
	$write_config_con_str='<?php $right = unserialize(\''.$write_config_con_str.'\');?>';//生成要写的内容
	$fp=fopen('../config/'.$type.'_config.php','w');
	fwrite($fp,$write_config_con_str,strlen($write_config_con_str));//将内容写入文件．
	fclose($fp);
	/*********************/
	admin_msg("module.php?m=company&s=user_right_config.php","设置成功");
	exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE><?php echo lang_show('admin_system');?></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<link href="main.css" rel="stylesheet" type="text/css" />
<script src="../script/prototype.js" type=text/javascript></script>
</head>
<body>
<div class="bigbox">
	<div class="bigboxhead tb">
	  <?php
	    @include_once('config/user_right'.$_GET['ctype'].'_config.php');
		@include_once('config/module_company_config.php');
		if(empty($module_company_config['identity']))
			admin_msg("module.php?m=company&s=module_config.php","请先设置会员身份");
		$ind=explode('|',$module_company_config['identity']);
		foreach($ind as $key=>$v){
	  ?>
	  <span class="cbox <?php if($_GET['ctype']==$key) echo 'on';?>">
	  <a href="module.php?m=company&s=user_right_config.php&ctype=<?php echo $key;?>"><?php echo $v;?></a>
	  </span>
	 <?php } ?>
	</div>
	<div class="bigboxbody">
	<form name="" action="" method="post">
	<table width="100%" cellspacing="0">
	<?php
	include_once($config['webroot'].'/lang/'.$config['language'].'/user_admin.php');
	include_once($config['webroot'].'/lang/'.$config['language'].'/admin_menu.inc.php');
	foreach($menu as $key=>$v){
	?>
	    <tr class="theader">
			<td><input <?php if(@in_array($v['name'],$right)){?>checked="checked"<?php } ?> name="index[]" type="checkbox" value="<?php echo $v['name'];?>" /> <?php echo $v['name'];?></td>
		</tr>
	    <tr>
		<td align="left">
		<?php
		foreach($v['sub'] as $skey=>$sv)
		{ 
			if(@in_array($sv['name'],$right))
				$sl='checked="checked"';
			else
				$sl='';
			echo '<label><input '.$sl.' style="margin-left:20px;" name="index[]" type="checkbox" value="'.$sv['name'].'" /> '.$sv['name'].'</label>';
		} 
		?></td></tr>
	<?php } ?>
		<tr><td><input  class="btn" type="submit" name="submit" value="<?php echo lang_show('submit');?>"></td></tr>
      </table>
	</form>
	</div>
</div>
</body>
</HTML>